<!DOCTYPE html>
<html>
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
	<title>编辑老人入院登记表</title>
	<#include "/common/resource.ftl">
    <link rel="stylesheet" href="${params.contextPath}/static/plug/layui/css/layui.css">
    <script type="text/javascript">
		$(function () {
		    // 加载性别、文化程度、婚姻状态列表
            $.ajaxRequest({
                url: '${params.contextPath}/web/dictionary/queryAcceptList',
                data: {dictionaryName: "sex"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var sexStr = "";
                    var record = data.data;
                    for (var i = 0; i < record.length; i++) {
                        sexStr += "<option value="+ record[i].value +">"+ record[i].name +"</option>";
                    }
                    $("#sex").append(sexStr);
                    layui.form.render();
                }
            });

            $.ajaxRequest({
                url: '${params.contextPath}/web/dictionary/queryAcceptList',
                data: {dictionaryName: "degree"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var degreeStr = "";
                    var record = data.data;
                    for (var i = 0; i < record.length; i++) {
                        degreeStr += "<option value="+ record[i].value +">"+ record[i].name +"</option>";
                    }
                    $("#eduDegree").append(degreeStr);
                    layui.form.render();
                }
            });

            $.ajaxRequest({
                url: '${params.contextPath}/web/dictionary/queryAcceptList',
                data: {dictionaryName: "maritalStatus"},
                success: function (data) {
                    if (!data.success) {
                        $.message(data.message);
                        return;
                    }
                    var maritalStatusStr = "";
                    var record = data.data;
                    for (var i = 0; i < record.length; i++) {
                        maritalStatusStr += "<option value="+ record[i].value +">"+ record[i].name +"</option>";
                    }
                    $("#maritalStatus").append(maritalStatusStr);
                    layui.form.render();
                }
            });

			<#if (params.id)??>
				$.ajaxRequest({
					url: '${params.contextPath}/web/elder/query',
					data: {id: "${params.id}"},
					success: function (data) {
						if (!data.success) {
							$.message(data.message);
							return;
						}
						var record = data.data.elder;
						for (var key in record) {
							$("[name='" + key + "']").val(record[key]);
						}
                        layui.form.render();
					}
				});
			</#if>
            $(".ajax-form").unbind().submit(function () {
                try {
                    var form = $(this);
                    if (!form.valid()) {
                        $.message("验证不通过，无法提交表单");
                        return false;
                    }

                    form.formSubmit({
                        callBack:function (data) {
                            <#if (params.tag)??>
                            history.go(-1);
                            </#if>
                        }
                    });
                } catch (e) {
                    console.log("表单提交错误：" + e);
                }
                return false;
            });
		});
	</script>
    <style>
        .layui-form-label{width:95px;}
        .layui-input-block{margin-left:125px;}
        .layui-card-header{font-weight:bold;}
        .layui-form select {display:none !important;}
    </style>
</head>
<body style="background:#eee;">
	<div style="padding:10px;">
		<form class="layui-form ajax-form" action="${params.contextPath}/web/elder/<#if (params.id)??>modify<#else>save</#if>" method="post">
			<input type="hidden" name="id" value="${params.id!}" />
            <div class="layui-card">
                <div class="layui-card-header">基本信息</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">姓名<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="name" placeholder="请输入姓名" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">出生年月<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="birthDate" placeholder="请输入出生年月" class="layui-input ui-date {required:true}" readonly/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">政治面貌<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="politicalOutlook" placeholder="请输入政治面貌" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <#if (params.tag)??>
                        <div class="layui-row">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">性别<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select id="sex" name="sex" class="layui-input {required:true}" lay-search>

                                        </select>
                                    </div>
                                </div>
                           </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">文化程度<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select id="eduDegree" name="eduDegree" class="layui-input  {required:true}" lay-search></select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">婚姻状况<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select id="maritalStatus" name="maritalStatus" class="layui-input {required:true}" lay-search></select>
                                    </div>
                                </div>
                            </div>
                        </div>
                    <#else>
                        <div class="layui-row">
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">性别<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select name="sex" dic-code="sex" class="layui-input dic-select {required:true}"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">文化程度<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select name="eduDegree" dic-code="degree" class="layui-input dic-select {required:true}"></select>
                                    </div>
                                </div>
                            </div>
                            <div class="layui-col-md4">
                                <div class="layui-form-item">
                                    <label class="layui-form-label">婚姻状况<span class="ui-request">*</span></label>
                                    <div class="layui-input-block">
                                        <select name="maritalStatus" dic-code="maritalStatus" class="layui-input dic-select {required:true}"></select>
                                    </div>
                                </div>
                            </div>
                        </div>

                    </#if>

                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">民族<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="nation" placeholder="请输入民族" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">籍贯<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="nativePlace" placeholder="请输入籍贯" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">曾从事职业<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="profession" placeholder="请输入曾从事职业" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">社保卡号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="socialCardNum" placeholder="请输入社保卡号" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">身份证号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="idcard" placeholder="请输入身份证号" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">户籍地址<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="address" placeholder="请输入户籍地址" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">生日<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="birthday" placeholder="请输入生日" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">习惯就诊医院</label>
                                <div class="layui-input-block">
                                    <input type="text" name="hospital" placeholder="请输入习惯就诊医院" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <#--this-->
                        </div>
                    </div>
                    <#--end-->
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">联系人信息</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">第一联系人<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactName1" placeholder="请输入第一联系人" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系人电话<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactPhone1" placeholder="请输入第一联系人电话" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">第二联系人</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactName2" placeholder="请输入第二联系人" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系人电话</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactPhone2" placeholder="请输入第二联系人电话" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">第三联系人</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactName3" placeholder="请输入第三联系人" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md6">
                            <div class="layui-form-item">
                                <label class="layui-form-label">联系人电话</label>
                                <div class="layui-input-block">
                                    <input type="text" name="contactPhone3" placeholder="请输入第三联系人电话" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                    </div>
                    <#--end-->
                </div>
            </div>
            <div class="layui-card">
                <div class="layui-card-header">经济、健康情况、信仰</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">经济来源<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="incomeSource" placeholder="请输入经济来源" class="layui-input {required:true}"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">宗教信仰</label>
                                <div class="layui-input-block">
                                    <input type="text" name="faith" placeholder="请输入宗教信仰" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <#--this-->
                        </div>
                    </div>
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">生活习惯<br/>兴趣爱好</label>
                                <div class="layui-input-block">
                                    <textarea name="habit" placeholder="请输入生活习惯、兴趣爱好" class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">主要病史<br/>药物过敏</label>
                                <div class="layui-input-block">
                                    <textarea name="medicalHistory" placeholder="请输入主要病史/药物过敏" class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">备注</label>
                                <div class="layui-input-block">
                                    <textarea name="remark" placeholder="请输入备注" class="layui-textarea"></textarea>
                                </div>
                            </div>
                        </div>
                    </div>
                    <#--end-->
                </div>
            </div>
            <#--<div class="layui-card">
                <div class="layui-card-header">入住信息</div>
                <div class="layui-card-body">
                    <div class="layui-row">
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">入院号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="code" placeholder="请输入入院号" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">房间ID<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="roomId" placeholder="请输入房间ID" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-col-md4">
                            <div class="layui-form-item">
                                <label class="layui-form-label">床位号<span class="ui-request">*</span></label>
                                <div class="layui-input-block">
                                    <input type="text" name="bedNum" placeholder="请输入床位号" class="layui-input"/>
                                </div>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">入住日期<span class="ui-request">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" name="checkInDate" placeholder="请输入入住日期" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">护理等级(字典项)<span class="ui-request">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" name="nursingLevel" placeholder="请输入护理等级(字典项)" class="layui-input"/>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label">优惠终止时间<span class="ui-request">*</span></label>
                            <div class="layui-input-block">
                                <input type="text" name="discountStopDate" placeholder="请输入优惠终止时间" class="layui-input"/>
                            </div>
                        </div>
                    </div>
                    &lt;#&ndash;end&ndash;&gt;
                </div>
            </div>-->

			<div class="layui-form-item">
				<div class="layui-input-block">
					<input type="submit" value="保存" class="layui-btn" />
				</div>
			</div>
		</form>
	</div>
</body>
<script src="${params.contextPath}/static/plug/layui/layui.all.js"></script>
</html>
